package com.hzcx.app.simplechat.chat.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.dao.ChatEmojiLikeDao;
import com.hzcx.app.simplechat.util.glide.GlideUtils;

import java.util.List;

public class ChatEmojiLikeAdapter extends BaseQuickAdapter<ChatEmojiLikeDao, BaseViewHolder> {

    private boolean isManager = false;

    public ChatEmojiLikeAdapter(@Nullable List<ChatEmojiLikeDao> data) {
        super(R.layout.rv_item_chat_emoji_like, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ChatEmojiLikeDao item) {
        if (helper.getAdapterPosition() == 0) {
            if(!isManager) {
                helper.setImageResource(R.id.iv_img, R.mipmap.ic_chat_emoji_like_add);
            }else {
                GlideUtils.loadImg(mContext, item.getPath(), helper.getView(R.id.iv_img));
            }
        } else {
            GlideUtils.loadImg(mContext, item.getPath(), helper.getView(R.id.iv_img));
        }

        if (isManager) {
            helper.setVisible(R.id.iv_check_box, true);
            if(item.isSelect()){
                helper.setImageResource(R.id.iv_check_box,R.mipmap.ic_icon_check_select);
            }else {
                helper.setImageResource(R.id.iv_check_box,R.mipmap.ic_icon_check_normal);
            }
        } else {
            helper.setVisible(R.id.iv_check_box, false);
        }
    }

    public void setManager(boolean isManager){
        this.isManager=isManager;
    }
}
